using System;
using System.Text;
using Microsoft.Practices.RecipeFramework;
using Microsoft.Practices.ComponentModel;
using EnvDTE;
using SPALM.SharePointSoftwareFactory.Library.Actions;

namespace SPALM.SharePointSoftwareFactory.Library.ValueProviders
{
    /// <summary>
    /// Provides the type of template which is used in the project, either VSEWSS-Format or HIVE Format
    /// </summary>
    [ServiceDependency(typeof(DTE))]
    public class VSTemplateTypeValueProvider : ValueProvider
    {
        public override bool OnBeginRecipe(object currentValue, out object newValue)
        {
            if (currentValue != null)
            {
                newValue = null;
                return false;
            }

            DTE dte = (DTE)this.GetService(typeof(DTE));
            Project project = Helpers2.GetSelectedProject(dte);

            if(Helpers2.IsVSTemplate(dte, project))
            {
                newValue = "VSEWSS";
                return true;
            }

            newValue = "HIVE";
            return true;
        }
    }
}
